<?php

namespace App\Admin\Validate\Account;

use App\Common\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class Store extends BaseValidate
{

    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    //字段待定
    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'store_name'=>'required',
                'business_mem_id'=>'required|integer|gt:0',
                'p_code'=>'sometimes',
                'c_code'=>'sometimes',
                'd_code'=>'sometimes',
                'address_area'=>'sometimes',
                'contact_name' => 'required|string|min:2|max:20',
            ];
            $this->message = [
                'store_name.required' => '门店名称不能为空',
                'business_mem_id.required' => '业务员未选择',
                'business_mem_id.integer' => '业务员参数错误',
                'business_mem_id.gt' => '业务员参数错误',
                'contact_name.required' => '负责人不能为空',
                'contact_name.min' => '负责人长度不能小于2位',
                'contact_name.max' => '负责人长度不能大于20位',
            ];
        } elseif($doaction=='edit') {
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'store_name'=>'required',
                'business_mem_id'=>'required|integer|gt:0',
                'p_code'=>'sometimes',
                'c_code'=>'sometimes',
                'd_code'=>'sometimes',
                'address_area'=>'sometimes',
                'contact_name' => 'required|string|min:2|max:20',
            ];
            $this->message = [
                'id.required' => '门店参数错误',
                'id.integer' => '门店参数错误',
                'id.gt' => '门店参数错误',
                'store_name.required' => '门店名称不能为空',
                'business_mem_id.required' => '业务员未选择',
                'business_mem_id.integer' => '业务员参数错误',
                'business_mem_id.gt' => '业务员参数错误',
                'contact_name.required' => '负责人不能为空',
                'contact_name.min' => '负责人长度不能小于2位',
                'contact_name.max' => '负责人长度不能大于20位',
            ];
        } elseif($doaction=='contractinfo') {//添加合同
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'contract_end_at'=>'required',
                'soft_year_fee'=>'required|integer|gt:0',
            ];
            $this->message = [
                'id.required' => '公司参数错误',
                'id.integer' => '公司参数错误',
                'id.gt' => '公司参数错误',
                'contract_end_at.required' => '合同续期时间未选择',
                'soft_year_fee.required' => '合同金额不能为空',
                'soft_year_fee.integer' => '合同金额格式不对',
                'soft_year_fee.gt' => '合同金额需大于0',
            ];
        }
    }
}
